package com.ruoyi.web.controller.shopping;

import com.ruoyi.system.domain.shopping.dto.CollectDto;
import com.ruoyi.system.service.shopping.CollectService;
import com.ruoyi.system.view.common.Result;
import com.ruoyi.web.controller.shopping.common.BaseContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/xiaomi/v2/collect")
public class CollectController {
    @Autowired
    private CollectService collectService;
    @GetMapping
    public Result<List<CollectDto>> list(){
        List<CollectDto> collectDtos = collectService.selectCollectDtoListByUserId(BaseContext.getId());
        return Result.success(collectDtos,"查询成功");
    }
    @PostMapping("/{productId}")
    private Result unCollect(@PathVariable Integer productId){

        Boolean aBoolean = collectService.goCollect(BaseContext.getId(), productId);
        return Result.success(aBoolean,"操作成功");
    }
}
